package bancosys.tec.persist.controller;

import org.hibernate.SessionFactory;

import bancosys.tec.component.AbstractController;
import bancosys.tec.persist.dao.BaseDAOFactory;
import bancosys.tec.persist.persister.PersisterFactory;
import bancosys.tec.security.SecurityService;

/**
 * Base controller.
 * 
 * @created Jan 23, 2007
 * @author Gustavo Almeida
 */
public abstract class AbstractPersistenceEnabledController extends AbstractController implements PersistenceEnabledController {
    protected BaseDAOFactory daoFactory;

    protected SecurityService securityService;

    /**
     * Session Factory.
     */
    protected SessionFactory sessionFactory = null;

    /**
     * Persister Factory.
     */
    protected PersisterFactory persisterFactory = null;

    /**
     * Devolve a fábrica de DAOs.
     * 
     * @return a fábrica de DAOs.
     */
    public BaseDAOFactory getDAOFactory() {
        return this.daoFactory;
    }

    /**
     * Devolve a session factory do hibernate.
     * 
     * @return a session factory do hibernate.
     */
    public SessionFactory getSessionFactory() {
        return this.sessionFactory;
    }

    /**
     * Define a session factory do hibernate.
     * 
     * @param sessionFactory session factory do hibernate.
     */
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    /**
     * Define o persisterFactory.
     * 
     * @param persisterFactory O persisterFactory a ser definido.
     */
    public void setPersisterFactory(PersisterFactory persisterFactory) {
        this.persisterFactory = persisterFactory;
    }

    /**
     * Devolve a persister factory.
     * 
     * @return a persister factory.
     */
    public PersisterFactory getPersisterFactory() {
        return this.persisterFactory;
    }

    /**
     * Define a DAO factory.
     * 
     * @param daoFactory DAO Factory.
     */
    public void setDaoFactory(BaseDAOFactory daoFactory) {
        this.daoFactory = daoFactory;
    }

    /**
     * Define o serviço de segurança.
     * 
     * @param securityService o serviço de segurança.
     */
    public void setSecurityService(SecurityService securityService) {
        this.securityService = securityService;
    }

    /**
     * Devolve o serviço de segurança.
     * 
     * @return o serviço de segurança.
     */
    public SecurityService getSecurityService() {
        return this.securityService;
    }
}
